/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2008                    */
/* Created on:     8/25/2014 22:08:24                           */
/*==============================================================*/


if exists (select 1
            from  sysobjects
           where  id = object_id('CONTACT')
            and   type = 'U')
   drop table CONTACT
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CUS_INFO')
            and   type = 'U')
   drop table CUS_INFO
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PRODUCT_INFO')
            and   type = 'U')
   drop table PRODUCT_INFO
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PRODUCT_TYPE')
            and   type = 'U')
   drop table PRODUCT_TYPE
go

/*==============================================================*/
/* Table: CONTACT                                               */
/*==============================================================*/
create table CONTACT (
   CONTACT_ID           int                  not null,
   FACEBOOK             varchar(254)         null,
   YAHOO                varchar(254)         null,
   PHONE                numeric              null,
   COMPANY              varchar(100)         null,
   EMAIL                varchar(100)         null,
   constraint PK_CONTACT primary key nonclustered (CONTACT_ID)
)
go

/*==============================================================*/
/* Table: CUS_INFO                                              */
/*==============================================================*/
create table CUS_INFO (
   CUS__USERNAME        varchar(100)         not null,
   PRO_ID               int                  not null,
   CONTACT_ID           int                  not null,
   CUS_NAME             varchar(100)         null,
   CUS_ADDRESS          varchar(254)         null,
   CUS_GENDER           bit                  null,
   CUS_PASSWORD         varchar(50)          not null,
   CUS_VIPACC           bit                  not null,
   constraint PK_CUS_INFO primary key nonclustered (CUS__USERNAME)
)
go

/*==============================================================*/
/* Table: PRODUCT_INFO                                          */
/*==============================================================*/
create table PRODUCT_INFO (
   PRO_ID               int                  not null,
   PRO_NAME             varchar(254)         not null,
   PRO_DESC             varchar(254)         not null,
   PRO_MANUF            varchar(50)          not null,
   PRO_PRICE            int                  not null,
   PRO_DATEUP           datetime             not null,
   PRO_ADDUP            varchar(100)         not null,
   constraint PK_PRODUCT_INFO primary key nonclustered (PRO_ID)
)
go

/*==============================================================*/
/* Table: PRODUCT_TYPE                                          */
/*==============================================================*/
create table PRODUCT_TYPE (
   TYPE_ID              numeric(100)         not null,
   PRO_ID               int                  not null,
   TYPE_NAME            varchar(100)         not null,
   constraint PK_PRODUCT_TYPE primary key nonclustered (TYPE_ID)
)
go

